package com.dm.cloud.core.service.user;

import com.dm.cloud.core.mode.UserMode;
import com.dm.cloud.core.util.ApplicationUtil;

/**
 * 用户工具类
 */
public class UserUtil {

    private static CurrentUserService getUserService(){
        CurrentUserService userService;
        try {
            userService = ApplicationUtil.getBean(CurrentUserService.class);
        }catch (Exception e){
            userService=new DefaultCurrentUserService();
        }
        if(userService==null){
            userService=new DefaultCurrentUserService();
        }
        return userService;
    }

    /**
     * 取用户信息
     * @return
     */
    public static UserMode currentUser(){
        return getUserService().getCurrentUser();
    }

    /**
     * 获取当前用户ID
     * @return
     */
    public static String currentUid(){
        return getUserService().uid();
    }

    /**
     * 获取当前用户名
     * @return
     */
    public static String currentUname(){
        return getUserService().uname();
    }

    /**
     * 获取当前用户中文名
     * @return
     */
    public static String currentChineseName(){
        return getUserService().uname();
    }
}
